

//品牌类型表returnJson转chartJson
function brandCategoryToChartJson(returnJson) {
    var chartsJson = [];//生成图表数据的json
    var titleJson = [];//标题
    var averagepriceJson = [];//平均价格
    var starJson = [];//平均星星数
    var starAmountJson = [];//平均星星评价数
    var commentamountJson = [];//平均评价数

    for (var i = 0 ;i <returnJson.length; i ++){
        titleJson.push(returnJson[i].fbrand+" "+returnJson[i].fcategory+"("+returnJson[i].fstar+"star)");
        averagepriceJson.push(returnJson[i].fproductprice);
        commentamountJson.push(returnJson[i].commentamount);
        starJson.push(returnJson[i].fstar);
        starAmountJson.push(returnJson[i].fstaramount);
    }

    chartsJson={"titleJson":titleJson,"averagepriceJson":averagepriceJson,"commentamountJson":commentamountJson,"starJson":starJson,"staramountJson":starAmountJson};

    return chartsJson;
}


//商品表returnJson转chartJson
function productToChartJson(returnJson) {
    var chartsJson = [];//生成图表数据的json
    var titleJson = [];//标题
    var dateTimeJson = [];//抓取时间
    var eanJson = [];//ean
    var averagepriceJson = [];//平均价格
    var maxpriceJson = [];//最高价格
    var minpriceJson = [];//最低价格
    var starJson = [];//平均星星数
    var starAmountJson = [];//平均星星评价数
    var commentamountJson = [];//平均评价数
    var ffollowsellquantityJson = [];//跟买数量

    for (var i = 0 ;i <returnJson.length; i ++){
        titleJson.push(returnJson[i].fbrand+"__"+returnJson[i].fcategory+"("+returnJson[i].fstar+"star)");
        dateTimeJson.push(returnJson[i].fdatetime);
        eanJson.push(returnJson[i].fproductean);
        averagepriceJson.push(returnJson[i].fproductprice);
        maxpriceJson.push(returnJson[i].fproductpricemax);
        minpriceJson.push(returnJson[i].fproductpricemin);
        commentamountJson.push(returnJson[i].commentamount);
        starJson.push(returnJson[i].fstar);
        starAmountJson.push(returnJson[i].fstaramount);
        ffollowsellquantityJson.push(returnJson[i].ffollowsellquantity);
    }

    chartsJson={"titleJson":titleJson,"dateTimeJson":dateTimeJson,"eanJson":eanJson,"averagepriceJson":averagepriceJson,"maxpriceJson":maxpriceJson,
        "minpriceJson":minpriceJson,"commentamountJson":commentamountJson,"starJson":starJson,"staramountJson":starAmountJson,
        "ffollowsellquantityJson":ffollowsellquantityJson};
    return chartsJson;
}


//跟卖商品表returnJson转chartJson
function followSellProductToChartJson(returnJson) {
    var chartsJson = [];//生成图表数据的json
    var titleJson = [];//标题
    var inventoryChangeJson = [];//库存变化
    var inventoryJson = [];//库存
    var nearestPriceJson = [];//最近一次价格
    var nearestCommentsJson = [];//最近一次评论数
    var nearestStarJson = [];//最近一次星星
    var nearestOneStarAmountJson = [];//最近一星数
    var nearestTwoStarAmountJson = [];//最近二星数
    var nearestThreeStarAmountJson = [];//最近三星数
    var nearestFourStarAmountJson = [];//最近四星数
    var nearestFiveStarAmountJson = [];//最近五星数

    for (var i = 0 ; i <returnJson.length; i ++){
        titleJson.push(returnJson[i].fsoldby);
        inventoryChangeJson.push(returnJson[i].finventorychange);
        inventoryChangeJson.push(returnJson[i].finventory);
        nearestPriceJson.push(returnJson[i].fproductprice);
        nearestCommentsJson.push(returnJson[i].fcommentamount);
        nearestStarJson.push(returnJson[i].fstar);
        nearestOneStarAmountJson.push(returnJson[i].fonestaramount);
        nearestTwoStarAmountJson.push(returnJson[i].ftwostaramount);
        nearestThreeStarAmountJson.push(returnJson[i].fthreestaramount);
        nearestFourStarAmountJson.push(returnJson[i].ffourstaramount);
        nearestFiveStarAmountJson.push(returnJson[i].ffivestaramount);
    }

    chartsJson={"titleJson":titleJson,"inventoryChangeJson":inventoryChangeJson,"finventory":inventoryJson,"nearestPriceJson":nearestPriceJson,"nearestCommentsJson":nearestCommentsJson,
        "nearestStarJson":nearestStarJson,"nearestOneStarAmountJson":nearestOneStarAmountJson,"nearestTwoStarAmountJson":nearestTwoStarAmountJson,
        "nearestThreeStarAmountJson":nearestThreeStarAmountJson,"nearestFourStarAmountJson":nearestFourStarAmountJson,"nearestFiveStarAmountJson":nearestFiveStarAmountJson};

    return chartsJson;
}



//品牌类型表returnJson转chartJson
function brandCategoryToChartJsonTest(returnJson) {
    var chartsJson = [];//生成图表数据的json
    var titleJson = [];//标题
    var averagepriceJson = [];//平均价格
    var starJson = []//平局星星数
    var commentamountJson = [];//平均评价数

    for (var i = 0 ;i <returnJson.length; i ++){
        titleJson.push(returnJson[i].brand+" "+returnJson[i].category+"("+returnJson[i].star+"star)");
        averagepriceJson.push(returnJson[i].averageprice);
        commentamountJson.push(returnJson[i].commentamount);
    }
    starJson = [100,200,233,342,234,333,444,234];

    chartsJson={"titleJson":titleJson,"averagepriceJson":averagepriceJson,"commentamountJson":commentamountJson,"starJson":starJson};

    return chartsJson;
}


